<?php

namespace app\admin\command;

use app\common\util\Tools;
use think\console\Input;
use think\console\Output;
use think\facade\Log;

class CouponTest extends CommonTest
{

    //再命令窗口中执行“php think interface-CouponTest”
    protected function configure()
    {
        $this->setName('interface-CouponTest')
            ->setDescription('接口测试');
    }

    public function execute(Input $input, Output $output)
    {
        parent::execute($input, $output);

        //Route::any('admin/coupon/create', 'admin/coupon/toAddCoupon');                                                          // 添加优惠券
        $data = Tools::curl($this->url . "admin/coupon/create", json_encode(["token" => "$this->token", "type" => "1", "name" => "xxxx", "condition" => "11", "amount" => 12, "timeFrom" => "2019", "timeTo" => "2019"]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

//        //Route::any('admin/coupon/getPageList', 'admin/coupon/getCouponList');                                                   // 优惠券列表，分页功能
        $data = Tools::curl($this->url . "admin/coupon/getPageList", json_encode(["token" => "$this->token"]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

        //Route::any('admin/coupon/getDetailsById', 'admin/coupon/getCouponDetail');                                              // 优惠券的详细信息
        $data = Tools::curl($this->url . "admin/coupon/getDetailsById", json_encode(["token" => "$this->token", "id" => 1]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

    }
}
